﻿using Architecture.Api.Application.Commands.DeepProcessingCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.DeepProcessingHandler
{
    public class DeepProcessingCorporationCreateCommandHandler : IRequestHandler<DeepProcessingCorporationCraeteCommand, int>
    {
        private readonly IDeepProcessingService _deepProcessingService;

        public DeepProcessingCorporationCreateCommandHandler(
            IDeepProcessingService deepProcessingService)
        {
            _deepProcessingService = deepProcessingService;
        }

        public async Task<int> Handle(DeepProcessingCorporationCraeteCommand request, CancellationToken cancellationToken)
        {
            return await _deepProcessingService.AddCorporation(new Corporation
            {
                CompanyName = request.CompanyName,
                CompanyPicture = request.CompanyPicture,
                ProductionLot = request.ProductionLot,
                ProductionLicense = request.ProductionLicense,
            });
        }
    }
}